home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / insserv / seq-changes < prev   
Text File  |  2009-09-07  |  1KB  |  55 lines

  1. #! /bin/bash
  2. # Script from Frans Pop
  3.  
  4. set -e
  5.  
  6. if [ -z "$1" ]; then
  7.     echo "Usage: insserv-seq-changes /var/lib/insserv/<old bootscripts tarball>"
  8.     exit 1
  9. fi
  10.  
  11. oldtar="$(tar tzf $1)"
  12. for i in S $(seq 0 6); do
  13.     echo "Runlevel $i"
  14.     new="$(cd /etc/rc$i.d; ls -1 [KS]* | sort | nl)"
  15.     old="$(echo "$oldtar" | grep "^rc$i.d/[KS]" | cut -d/ -f2 | sort | nl)"
  16.     case $i in
  17.         S|0|6)
  18.         old="$(echo "$old" | sed -r "s/[KS][0-9]+//")"
  19.         new="$(echo "$new" | sed -r "s/[KS][0-9]+//")"
  20.         ;;
  21.         *)
  22.         old="$(echo "$old" | sed -r "s/([KS])[0-9]+/\1_/")"
  23.         new="$(echo "$new" | sed -r "s/([KS])[0-9]+/\1_/")"
  24.         ;;
  25.     esac
  26.     echo "$new" | while read num cmd; do
  27.         oldnum=$(echo "$old" | grep "[[:space:]]$cmd$" | awk '{print $1}')
  28.         if [ "$oldnum" ]; then
  29.             diff=$(($num - $oldnum))
  30.         else
  31.             oldnum="---"
  32.             diff=""
  33.         fi
  34.         if [ ${#cmd} -ge 16 ]; then
  35.             echo -e "$cmd\t$num\t$oldnum\t$diff"
  36.         elif [ ${#cmd} -ge 8 ]; then
  37.             echo -e "$cmd\t\t$num\t$oldnum\t$diff"
  38.         else
  39.             echo -e "$cmd\t\t\t$num\t$oldnum\t$diff"
  40.         fi
  41.     done
  42.     echo "$old"  | while read num cmd; do
  43.         if ! echo "$new" | grep -q "[[:space:]]$cmd$"; then
  44.             if [ ${#cmd} -ge 16 ]; then
  45.                 echo -e "$cmd\t---\t$oldnum"
  46.             elif [ ${#cmd} -ge 8 ]; then
  47.                 echo -e "$cmd\t\t---\t$oldnum"
  48.             else
  49.                 echo -e "$cmd\t\t\t---\t$oldnum"
  50.             fi
  51.         fi
  52.     done
  53.     echo
  54. done
  55.